﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="loginTitle" ContentPlaceHolderID="TitleContent" runat="server">
    <%=ViewData["SiteName"] %>
    -
    <%=ViewData["PageTitle"]%>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeaderContent" runat="server">
    <style type="text/css">
        label.error
        {
            float: none;
            color: red;
            padding-left: .5em;
            vertical-align: top;
        }
        label
        {
            display: block;
            font-weight: bold;
        }
        #divOpenIdIcons
        {
            margin-top: 5px;
            margin-left: 30px;
        }
        #divOpenIdIcons img
        {
            border: 1px solid silver;
            cursor: pointer;
        }
        .hoverbutton:hover, .pagebutton:hover
        {
            -moz-background-clip: border;
            -moz-background-inline-policy: continuous;
            -moz-background-origin: padding;
            background: white url(images/menuhighlight.png) repeat scroll 0 0;
            border: 1px solid silver;
            color: Black;
            text-decoration: none;
        }
        .hoverbutton, .pagebutton
        {
            border: 1px solid transparent;
            font-size: 8pt;
            margin-right: 5px;
            padding: 2px;
            text-decoration: none;
        }
    </style>
</asp:Content>
<asp:Content ID="loginContent" ContentPlaceHolderID="MainContent" runat="server">
    <div class="contentpage-outerdiv">
        <h2>
            Log On</h2>
        <%if (bool.Parse(ViewData["AllowOpenIdRegistration"].ToString()))
          { %>
        <p>
            Please log in using either <a href="http://openid.net/get-an-openid/" target="_blank">
                OpenID</a> or a UserName and Password or <b>
                    <%= Html.ActionLink("Register", "Register")%></b> a new account.
        </p>
        <%}
          else
          {%>
        <p>
            Please enter your username and password.
            <%= Html.ActionLink("Register", "Register")%>
            if you don't have an account.
        </p>
        <%} %>
        <span class="field-validation-error">&nbsp;<%= Html.ValidationSummary("Login was unsuccessful. Please correct the errors and try again.") %>
            <%=ViewData["message"]%>
        </span>
        <div class="resource-body">
            <%=ViewData["resourcebody"]%></div>
        <%if (string.IsNullOrEmpty(ViewData["OpenId"].ToString()) && bool.Parse(ViewData["AllowOpenIdRegistration"].ToString()))
          { %>
        <% using (Html.BeginForm(new { Controller = "Account", Action = "OpenIdLogon" }))
           { %>
        <fieldset>
            <div class="containercontent" style="padding: 10px 20px;">
                <div class="labelheaderblock">
                    Log on using OpenId:</div>
                <input id="openid_identifier" name="openid_identifier" size="40" />
                <input id="btnOpenIdLogin" type="submit" value="Login" />
                <img id="imgOpenIdLoginProgress" src="<%= ResolveUrl("~/content/images/loading_small.gif") %>"
                    style="display: none" />
                <div id="divOpenIdIcons">
                    <img src="<%= ResolveUrl("~/content/images/openid-icon.png") %>" onclick="openIdUrl('openid')"
                        title="myopenid.com" class="hoverbutton" />
                    <img src="<%= ResolveUrl("~/content/images/google-icon.png") %>" onclick="openIdUrl('google')"
                        title="Google" class="hoverbutton" />
                    <img src="<%= ResolveUrl("~/content/images/yahoo-icon.png") %>" onclick="openIdUrl('yahoo')"
                        title="Yahoo" class="hoverbutton" />
                </div>
            </div>
        </fieldset>
        <%=Html.Hidden("returnUrl", ViewData["referer"].ToString())%>
        <% }
          }%>
        <% using (Html.BeginForm(new { Controller = "Account", Action = "Logon" }))
           { %>
        <div>
            <fieldset>
                <legend>Account Information</legend>
                <p>
                    <label for="username">
                        UserName:</label>
                    <%= Html.TextBox("username", ViewData["OpenId"], new { @class = "required" })%>
                    <%= Html.ValidationMessage("username") %>
                </p>
                <p>
                    <label for="password">
                        Password:</label>
                    <%= Html.Password("password", "", new { @class = "required" })%>
                    <%= Html.ValidationMessage("password") %>
                </p>
                <p>
                    <%= Html.CheckBox("rememberMe") %>
                    <label class="inline" for="rememberMe">
                        Remember me?</label>
                </p>
                <p>
                    <input type="submit" value="Log On" />
                </p>
            </fieldset>
        </div>
        <%=Html.Hidden("returnUrl", ViewData["referer"].ToString())%>
        <% } %>
    </div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="ScriptContent" runat="server">

    <script src="/Scripts/jquery.validate.min.js" type="text/javascript"></script>

    <script type="text/javascript">
        $("#form1").validate({
            submitHandler: function(form) {
                form.submit();
            }
        });
        $(document).ready(function() {
            $("#btnOpenIdLogin").click(function() {
                $(this).hide();
                $("#imgOpenIdLoginProgress").show();
            });
        });


        function openIdUrl(site) {
            var value = "";
            var autoClick = false;

            if (site == "openid") {
                value = "<Your Account>.myopenid.com"
            }
            else if (site == "google") {
                value = "https://www.google.com/accounts/o8/id";
                autoClick = true;
            }
            else if (site == "yahoo") {
                value = "http://yahoo.com/"
                autoClick = true;
            }

            if (value) {
                var jText = $("#openid_identifier");
                jText.val(value)
            .focus();
                if (autoClick)
                    $("#btnOpenIdLogin").trigger("click");
            }

        }	
	
    </script>

</asp:Content>
